﻿/*
 * Almathy Center - LicenceWindow.xaml.cs
 * Copyright (C) 2011 Christophe LEMOINE
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * */
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;

namespace AlmathyCenter
{

    /// <summary>
    /// Logique d'interaction pour LicenceWindow.xaml
    /// </summary>
    public partial class LicenceWindow : Window
    {

        public LicenceWindow()
        {
            InitializeComponent();
            string path = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + System.IO.Path.DirectorySeparatorChar.ToString();
            if(!File.Exists(path + "licence.rtf"))
            {
                MessageBox.Show(this, "Le fichier contenant la licence GPL v3 est introuvable dans le dossier de l'application!", "Erreur", MessageBoxButton.OK, MessageBoxImage.Error);
                RichTextBox1.AppendText("http://www.gnu.org/licenses/gpl-3.0.txt");
                return;
            }
            FileStream fs = new FileStream(path + "licence.rtf", FileMode.Open);
            RichTextBox1.Document.Blocks.Clear();
            TextRange tr = new TextRange(RichTextBox1.Document.ContentStart, RichTextBox1.Document.ContentEnd);
            tr.Load(fs, DataFormats.Rtf);
        }

        private void LkClicked(object sender, MouseButtonEventArgs e)
        {
            Process p = new Process();
            p.StartInfo = new ProcessStartInfo((sender as Label).ToolTip.ToString());
            p.Start();
        }

    }

}
